﻿/**
 * Created with JetBrains WebStorm.
 * User: kane
 * Date: 13-2-27
 * Time: 下午6:57
 * To change this template use File | Settings | File Templates.
 */
var User = require('../bean/DBuser');

exports.main = function(args,req, res){
    //db:[{m:"read",name:"a"}]
    User.get(args.name,function(err,user){
        if(err){
            res.render('info', {error:err });
            return;
        }

        if(!user){
            res.render('info', {error:'登录失败！' });
            return;
        }

        logger.info("用户登录：name="+user.name+";sessionID="+req.sessionID+";ip="+req.ip+";user-agent="+req.headers['user-agent']);
        req.session.user = user;
        res.render('index', {user:user,success:'ok'});
    });
};